package com.example.stringbufferlogger.mapper;

import com.example.stringbufferlogger.entity.GPSDealCompareData;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface GPSDealCompareDataMapper {
    /**
     * 批量插入 GPSDealCompareData 数据
     * @param dataList 待插入的 GPSDealCompareData 数据列表
     * @return 插入成功的记录数
     */
    @Insert("<script>" +
            "INSERT ALL " +
            "<foreach collection=\"dataList\" item=\"item\">" +
            "INTO gps_deal_compare_data (compare_id, log_id, api_id, new_data, old_data, table_name, policyno, source) " +
            "VALUES (#{item.compareId}, #{item.logID}, #{item.apiId}, #{item.newData, jdbcType=VARCHAR}, " +
            "#{item.oldData, jdbcType=VARCHAR}, #{item.tableName, jdbcType=VARCHAR}, " +
            "#{item.policyno, jdbcType=VARCHAR}, #{item.source, jdbcType=VARCHAR}) " +
            "</foreach>" +
            "SELECT 1 FROM DUAL" +
            "</script>")
    int insertBatchSomeColumn(@Param("dataList") List<GPSDealCompareData> dataList);

    void insertEntity(GPSDealCompareData data);

}

